package com.zhxl.server.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.zhxl.server.model.Goods;

@Mapper
public interface GoodsDao {

    @Select("select * from goods t where t.id = #{id}")
    Goods getById(Long id);

    @Delete("delete from goods where id = #{id}")
    int delete(Long id);

    int update(Goods goods);
    
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into goods(saleUnit, weight, productArea, wareQD, imagePath, param, state, sku, brandName, upc, category, name, introduction, skuId, jdPrice, price, normalPrice, merchantsPrice, marketPrice, tax, taxPrice, nakedPrice, type, create_time) values(#{saleUnit}, #{weight}, #{productArea}, #{wareQD}, #{imagePath}, #{param}, #{state}, #{sku}, #{brandName}, #{upc}, #{category}, #{name}, #{introduction}, #{skuId}, #{jdPrice}, #{price}, #{normalPrice}, #{merchantsPrice}, #{marketPrice}, #{tax}, #{taxPrice}, #{nakedPrice}, #{type}, #{createTime})")
    int save(Goods goods);
    
    int count(@Param("params") Map<String, Object> params);

    List<Goods> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);
}
